package com.yidu.ruifeng_logistics.service.impl;

import com.yidu.ruifeng_logistics.entity.LogisticsOrder;
import com.yidu.ruifeng_logistics.dao.LogisticsOrderDao;
import com.yidu.ruifeng_logistics.entity.LogisticsOrderVo;
import com.yidu.ruifeng_logistics.entity.LogisticsWaybill;
import com.yidu.ruifeng_logistics.service.LogisticsOrderService;
import com.yidu.ruifeng_logistics.vo.LineVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (LogisticsOrder)表服务实现类
 *
 * @author makejava
 * @since 2021-03-09 14:24:41
 */
@Service("logisticsOrderService")
public class LogisticsOrderServiceImpl implements LogisticsOrderService {
    @Resource
    private LogisticsOrderDao logisticsOrderDao;

    /**
     * 通过ID查询单条数据
     *
     * @param orderId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsOrder queryById(Integer orderId) {
        return this.logisticsOrderDao.queryById(orderId);
    }

    @Override
    public LogisticsOrderVo selectById(Integer orderId) {
        return this.logisticsOrderDao.selectById(orderId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsOrder> queryAllByLimit(int offset, int limit) {
        return this.logisticsOrderDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsOrder 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsOrder insert(LogisticsOrder logisticsOrder) {
        this.logisticsOrderDao.insert(logisticsOrder);
        return logisticsOrder;
    }

    /**
     * 修改数据
     *
     * @param logisticsOrder 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsOrder update(LogisticsOrder logisticsOrder) {
        this.logisticsOrderDao.update(logisticsOrder);
        return this.queryById(logisticsOrder.getOrderId());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer orderId) {
        return this.logisticsOrderDao.deleteById(orderId) > 0;
    }

    @Override
    public List<LogisticsOrderVo> queryAll(LogisticsOrderVo logisticsOrderVo) {
        return this.logisticsOrderDao.queryAll(logisticsOrderVo);
    }

    @Override
    public List<LogisticsOrderVo> notQueryAll(LogisticsOrderVo logisticsOrderVo) {
        return this.logisticsOrderDao.notQueryAll(logisticsOrderVo);
    }

    /**
     * 查询路线
     * @return
     */
    @Override
    public List<LineVo> queryLine() {
        return this.logisticsOrderDao.queryLine();
    }

    @Override
    public int updataLine(LogisticsOrder logisticsOrder) {
        return this.logisticsOrderDao.updataLine(logisticsOrder);
    }

    /**
     * 修改同一运单的订单数据
     * @param waybill
     * @return
     */
    @Override
    public int updateWaybillId(LogisticsWaybill waybill) {
        return this.logisticsOrderDao.updateWaybillId(waybill);
    }


}
